package com.ustc.hewei.snowflakemodule.segment.entity;

/**
 * @author hewei
 * @version 1.0
 * @description: Segment模式获取ID返回的结果
 * @date 2022/11/16 15:56
 */

public class ResultId {
    private long id;
    private int failCode;
    private boolean isSuccess;

    public long getId() {
        return id;
    }

    public int getFailCode() {
        return failCode;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public ResultId(long id, boolean isSuccess) {
        this.id = id;
        this.isSuccess = isSuccess;
    }

    public ResultId(int failCode, boolean isSuccess) {
        this.failCode = failCode;
    }

    public static ResultId fail(int failCode) {
        return new ResultId(failCode, false);
    }

    public static ResultId ok(long id) {
        return new ResultId(id, true);
    }

    @Override
    public String toString() {
        return "ResultId{" +
                "id=" + id +
                ", failCode=" + failCode +
                ", isSuccess=" + isSuccess +
                '}';
    }
}
